import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/

export const defaultRouters = [
  // { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  // { path: '/404', component: () => import('@/views/404'), hidden: true },
  // { path: '*', redirect: '/404', hidden: true },
  // {
  //   path:'/',
  //   component:Layout,
  //   name:'demo',
  //   hidden: true ,
  // },
  {
    path: '/baseInfo',
    component: Layout,
    name: 'baseInfo',
    meta: { title: '基本信息' },
    redirect:'baseInfo/carInfo',
    alwaysShow:true,
    children: [
      {
      path: 'carInfo',
      name:'carInfo',
      // component: () => import('@/views/baseInfo/carInfo'),
      component: () => import('@/views/meeting/index'),

      meta:{title:'车辆信息'}
     },
      {
      path: 'automachineInfo',
      name: 'automachineInfo',
      component: () => import('@/views/baseInfo/automachineInfo'),
      meta: { title: '自动售货机信息', }
      },  
      {
        path: 'goodsInfo',
        name: 'goodsInfo',
        component: () => import('@/views/baseInfo/goodsInfo'),
        meta: { title: '商品信息', }
      },
      {
        path: 'dispatchInfo',
        name: 'dispatchInfo',
        component: () => import('@/views/baseInfo/dispatchInfo'),
        meta: { title: '配送信息', }
        },  
      ]
    },

    {
      path: '/meeting',
      component: Layout,
      name: 'meeting',
      meta: { title: '所有会议' },
      children: [{
        path: 'meeting',
        component: () => import('@/views/meeting/index')
      }]
    },

    {
      path: '/reviseMember',
      component: Layout,
      name: 'reviseMember',
      meta: { title: '配送管理' },
      children: [{
        path: 'index',
        component: () => import('@/views/reviseMember/index')
      }]
    },
    {
      path: '/fillRecord',
      component: Layout,
      name: 'fillRecord',
      meta: { title: '补货记录' },
      children: [{
        path:'fillRecord',
        component:() => import('@/views/fillRecord/index')
      }]
    },
    {
      path: '/checkManage',
      component: Layout,
      name: 'checkManage',
      meta: { title: '审核管理' },
      children: [{
        path:'index',
        component:() => import('@/views/checkManage/index')
      }]
    },
    {
      path: '/systemManage',
      component: Layout,
      name: 'systemMange',
      meta: { title: '系统管理' },
      redirect:'systemMange/memberStructure',
      alwaysShow:true,
      
      children: [
        {
        path: 'memberStructure',
        name:'memberStructure',
        component: () => import('@/views/systemManage/memberStructure'),
        meta:{title:'组织结构'}
        },
        {
        path: 'userManage',
        name: 'userManage',
        component: () => import('@/views/systemManage/userManage'),
        meta: { title: '用户管理', }
        },  
        {
          path: 'roleManage',
          name: 'roleManage',
          component: () => import('@/views/systemManage/roleManage'),
          meta: { title: '角色管理', }
        },
      ]
  },
]

export const constantRouterMap=[
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path:'/',
    component:Layout,
    name:'demo',
    hidden: true ,
  },

]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

